<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>周边商家</title>
    <link rel="stylesheet" href="../../css/amazeui.min.css">
    <link rel="stylesheet" href="css/app.css">
    <style>
    	body{
    		
    	}
    </style>
</head>
<body>


<div id='header' class="am-g am-topbar-fixed-top" >
	<div  onclick="api.closeWin();"  class="am-u-sm-2" style="margin-top:12px;padding-left: 17px">
		<img  src="images/arr-l.png" style="height:14px;height: 18px;"/>
	</div> 
	<div class="am-u-sm-8 til" style="margin-top:13px;text-align:center;">
		<h1>周边商家</h1>
	</div>
	<div class="am-u-sm-2" style="font-size: 20px;margin-top:10px;color:white;text-align:center;">

   </div>
</div>



<div class="am-g" style="margin-top:50px" id="surroundlist">

	<!--<div class="am-u-sm-12" style="border-bottom:1px solid #e5e5e5;padding:8px;">
	     		   
		 <div class="am-u-sm-10" style="padding:0px;border-right: 1px solid #e5e5e5;">
			<div class="am-u-sm-12" style="padding:0px;color:#393939;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
				汇德大厦-停车场
			</div>
	
			<div class="am-u-sm-12" style="padding:0px;color:#393939;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
				
			</div>
			
			<div class="am-u-sm-12" style="padding:0px;color:#000000;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; align:right ">
				距离:&nbsp;&nbsp;
			</div>
			
			
			<div class="am-u-sm-12 am-text-truncate" style="padding:0px;color:#949494;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
			  	 	越秀区豪贤路102号
			</div>
			
		</div>
		
		<div class="am-u-sm-2" style="vertical-align: middle;text-align: center;">
		     <i class="am-icon-phone am-icon-sm" style="line-height:80px;color:green;"></i>
		</div>
		
		
	</div>-->

</div>




	
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">

  
	var datalist = [];
	
	var longitude;//经度
	var latitude;//维度
	
	
	
	apiready = function(){
	    
	    var baiduLocation = api.require('baiduLocation');
		baiduLocation.startLocation({
		    accuracy: '100m',
		    filter:1,
		    autoStop: true
		}, function(ret, err){
		    var sta = ret.status;
		    var lat = ret.latitude;
		    var lon = ret.longitude;
		    var t = ret.timestamp;
		    if(sta){
		        longitude=lon;    //经度
		        latitude=lat;    //维度
		        
		        init();
		        
		    } else{
		        api.alert({msg:err.msg});
		    }
		});
	
	
		
	};
	
	
	//初始化数据
	function init(){

	      do_ajax('/app/surround?longitude='+longitude+'&latitude='+latitude,'get',{},function(ret,err){
				  if(ret){
		                datalist=ret.datas;
					    var dataHtml = '';
					    if(datalist.length>0){
					    
					       for(var i=0;i<datalist.length;i++){
						        dataHtml += '<div class="am-u-sm-12" style="border-bottom:1px solid #e5e5e5;padding:8px;">'
					        		
							    		    dataHtml += '<div class="am-u-sm-10" onclick="surroundinfo('+i+');" style="padding:0px;border-right: 1px solid #e5e5e5;">';
								    		    dataHtml += '<div class="am-u-sm-12" style="padding:0px;color:#393939;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">';
								    		    dataHtml += datalist[i].name;
								    		    dataHtml += '</div>';
								    		    if(datalist[i].project){
								    		        dataHtml += '<div class="am-u-sm-12" style="padding:0px;color:#393939;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">';
									    		    dataHtml += datalist[i].project;
									    		    dataHtml += '</div>';
								    		    }
								    		    
								    		    dataHtml += '<div class="am-u-sm-12" style="padding:0px;color:#000000;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; align:right ">';
								    		    dataHtml += '距离:&nbsp;&nbsp;'+datalist[i].distance+'';
								    		    dataHtml += '</div>';
								    		    dataHtml += '<div class="am-u-sm-12 am-text-truncate" style="padding:0px;color:#949494;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">';
								    		    dataHtml += datalist[i].address;
								    		    dataHtml += '</div>';
					    		    
					    		            dataHtml += '</div>';
					    		            
					    		           
					    		            if(datalist[i].tel){
					    		               dataHtml+='<div class="am-u-sm-2"  onclick="api.call({type:"tel_prompt",number:'+datalist[i].tel+'});" style="vertical-align: middle;text-align: center;">';
					    		               dataHtml+='<i class="am-icon-phone am-icon-sm" style="line-height:80px;color:green;"></i>';
					    		            }else{
					    		               dataHtml+='<div class="am-u-sm-2"  style="vertical-align: middle;text-align: center;">';
					    		               dataHtml+='<i class="am-icon-phone am-icon-sm" style="line-height:80px;color:red;"></i>';
					    		            }
					    		            
					    		            dataHtml+= '</div>';

					            dataHtml += '</div>';
					            
					            
					         }
				        
					    }else{
					       
					       dataHtml += '<div  class="am-u-sm-12" style="margin-top:10px;text-align:center">暂无数据...</div>'
					         
					    }
                          
				    
				        $api.html($api.byId('surroundlist'), dataHtml);
						
						api.hideProgress();
					    
				       }else{
				            api.alert({
					            msg:('错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode)
					        });
					        api.hideProgress();
				       }
			   });
	      
	      
	
    };
    
    //商家详情
    function surroundinfo(index){
        openWin('surroundinfo',{'data':datalist[index]});
    };
	
	
	
	
	
	
</script>
</html>